package rxjava2.groccery;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class BracketSentenceHelper {

    private static String outerSentence;
    private static String bracketSentence;

    public static void main(String[] args) {
        InputStreamReader reader = new InputStreamReader(System.in);

        try {
            outerSentence = new BufferedReader(reader).readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }

        InputStreamReader bracketReader = new InputStreamReader(System.in);
        try {
            bracketSentence = new BufferedReader(bracketReader).readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }

        String mix = mix(outerSentence, bracketSentence);
        System.out.println("final words: "+mix);
    }

    private static String mix(String outerSentence, String bracketSentence) {
        int outLen = outerSentence.length();
        int bracketLen = bracketSentence.length();
        boolean endBracket = false;
        StringBuffer stringBuffer = new StringBuffer(outLen);

        for (int i = 0; i < outLen; i++) {
            if (i >= bracketLen)
                endBracket = true;

            stringBuffer.append(outerSentence.charAt(i));
            if (!endBracket) {
                stringBuffer.append('（');
                stringBuffer.append(bracketSentence.charAt(i));
                stringBuffer.append("）");
            }

        }

        return stringBuffer.toString();
    }
}
